package com.graphhopper.util.buffer;


import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.operation.buffer.BufferOp;

/**
 * 多边形缓冲区域实现类
 * @author: heguanglong
 * @date: 2020-12-26
 **/
public class PolygonBufferImpl extends BufferBase implements BufferStrategy {
    @Override
    public String addBuffer(String gps, double rd) {
        Geometry polygon = geometryFactory.createPolygon(getCoordinate(gps));
        Geometry buffer = getBuff(polygon, BufferOp.CAP_ROUND, rd);
        return gpsToString(buffer.getCoordinates());
    }

    @Override
    public String geometryInfo(String gps, double rd) {
        return getBuff(geometryFactory.createPolygon(getCoordinate(gps)), BufferOp.CAP_ROUND, rd).toString();
    }
    @Override
    public Geometry geometry(String gps) {
        return geometryFactory.createPolygon(getCoordinate(gps,"\\,"," "));
    }
}
